<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <head>
        <title>我的书架_{{ website.name }}</title>
        <meta name="keywords" content="我的书架,个人中心,{{ website.name }}小说,{{ website.name }}" />
        <meta name="description"
            content="{{ website.name }}小说每日更新小说连载,小说排行榜,提供言情小说,都市小说,玄幻小说,穿越小说,青春小说,总裁豪门小说,网络小说,免费小说,全本小说,首发小说,最新章节免费小说阅读,精彩尽在{{ website.name }}小说！" />
        <link rel="stylesheet" href="/static/css/user.css" />
        {% include 'common/header.html' %}
    </head>
</head>

<body class="">

    {% include 'common/top.html' %}

    <div class="main box_center cf">
        <div class="userBox cf">
            {% include 'user/common.html' %}
            <div class="my_r">
                <div class="my_bookshelf">
                    <div class="title cf">
                        <h2 class="fl"><a href="javascript:void(0);" class="red">我的书架</a></h2><i
                            class="fl ml20 mr20 font16">|</i>
                        <h2 class="fl"><a href="/user/read_history.html">最近阅读</a></h2>
                    </div>

                    <div id="divData" class="updateTable">
                        <table cellpadding="0" cellspacing="0">
                            <thead>
                                <tr>
                                    <th class="style">
                                        类别
                                    </th>
                                    <th class="name">
                                        书名
                                    </th>
                                    <th class="chapter">
                                        最新章节
                                    </th>
                                    <th class="time">
                                        更新时间
                                    </th>
                                    <th class="goread">
                                        书签
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="bookShelfList">



                            </tbody>
                        </table>
                        <div class="pageBox cf" id="shellPage">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    {% include 'common/footer.html' %}


</body>
{% include 'common/js.html' %}
<script src="/static/javascript/user.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    search(1, 10);

    function search(curr, limit) {

        $.ajax({
            type: "get",
            url: "/user/listBookShelfByPage",
            data: { 'page': curr, 'limit': limit },
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                    var bookShelfList = data.data;
                    if (bookShelfList.length > 0) {
                        var bookShelfListHtml = "";
                        for (var i = 0; i < bookShelfList.length; i++) {
                            var book = bookShelfList[i];
                            bookShelfListHtml +=
                            `
                            <tr class="book_list" vals="291">
                                <td class="style bookclass">
                                    <a href="/book/bookclass.html?c=${book.cat_id}">[${book.cat_name}]</a>
                                </td>
                                <td class="name">
                                    <a href="/book/${book.book_id}.html">${book.book_name}</a>
                                </td>
                                <td class="chapter" valsc="291|2037554|1">
                                    <a href="/book/${book.book_id}/${book.last_index_id}.html">${book.last_index_name}</a>
                                </td>
                                <td class="time">
                                    ${layui.util.toDateString(book.last_index_update_time, "MM/dd HH:mm")}
                                </td>
                                <td class="goread">
                                    <a href="/book/${book.book_id}/${book.pre_content_id}.html">继续阅读</a>
                                </td>
                            </tr>
                            `;
                        }
                        $("#bookShelfList").html(bookShelfListHtml);

                        layui.use('laypage', function () {
                            var laypage = layui.laypage;

                            //执行一个laypage实例
                            laypage.render({
                                elem: 'shellPage' //注意，这里的 test1 是 ID，不用加 # 号
                                , count: data.count //数据总数，从服务端得到,
                                , curr: data.page
                                , limit: data.limit
                                , jump: function (obj, first) {


                                    //obj包含了当前分页的所有参数，比如：
                                    //console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                                    //console.log(obj.limit); //得到每页显示的条数


                                    //首次不执行
                                    if (!first) {
                                        search(obj.curr, obj.limit);
                                    } else {

                                    }
                                }
                            });
                        });

                    }


                } else if (data.code == 1001) {
                    //未登录
                    location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);

                } else {
                    layer.alert(data.msg);
                }

            },
            error: function () {
                layer.alert('网络异常');
            }
        })

    }
</script>

</html>